home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / CDTools / S / UpdateIndices < prev    next >
Text File  |  2001-06-04  |  3KB  |  107 lines

  1. /*
  2.     Update local index files
  3.     $VER: UpdateIndices 1.1 (8.11.2000)
  4.     by Neil Bothwick
  5.  
  6.     1.1  - Uses "parse source" to get the name of the CD
  7. */
  8.  
  9. /* ;;; Initialise */
  10. options results
  11. address command
  12. signal on error
  13. call LoadLib('rexxsupport.library')
  14. call LoadLib('rexxdossupport.library')
  15.  
  16. parse source . ' ' . ' ' . ' ' ScriptName ' ' .
  17. CDName = left(ScriptName, pos(':', ScriptName) - 1)
  18. ;;;
  19. /* ;;; Ask whether the user wishes to update */
  20. if pos('AUTUP=Automatic',GetVar('AACD.prefs',Global,Binary)) = 0 then do
  21.     if length(GetVar('AACDIndex')||GetVar('AminetCDIndex')||GetVar('AminetSetIndex')||GetVar('AminetIndex')) = 0 then exit
  22.     'RequestChoice >ENV:AAUpdateNow "Amiga Active CD" "Do you wish to update the CD index*Nfiles on your hard drive with the new*Nones from the CD?" "Yes|No"'
  23.     if GetVar('AAUpdateNow') = 0 then do
  24.         call ShowMsg('This requester should not appear again.*NYou may update the index files at any time*Nfrom the Search section of AACDprefs')
  25.         call delete('ENV:AAUpdateNow')
  26.         exit
  27.         end
  28.     call delete('ENV:AAUpdateNow')
  29.     end
  30. ;;;
  31. /* ;;; Update Index files */
  32. /* AACD indices */
  33. DestDir = GetVar('AACDIndex')
  34. SrcDir = CDName':CDTools/Indices'
  35. Pattern = ParsePattern('AACD??',NOCASE)
  36. if DestDir > '' then call CopyFiles()
  37.  
  38. /* Aminet CD indices */
  39. DestDir = GetVar('AminetCDIndex')
  40. SrcDir = CDName':AACD/Resources/CDROM/Aminet/CDs'
  41. Pattern = ParsePattern('Index??',NOCASE)
  42. if DestDir > '' then call CopyFiles()
  43.  
  44. /* Aminet Set indices */
  45. DestDir = GetVar('AminetSetIndex')
  46. SrcDir = CDName':AACD/Resources/CDROM/Aminet/Sets'
  47. Pattern = ParsePattern('Set?',NOCASE)
  48. if DestDir > '' then call CopyFiles()
  49.  
  50. /* Aminet Online indices */
  51. DestDir = GetVar('AminetIndex')
  52. if DestDir > '' then do
  53.     SrcDir = CDName':AACD/Resources/Online/Aminet'
  54.     call DateCopy('INDEX')
  55.     call DateCopy('dirlist')
  56.     call open(List,AddPart(SrcDir,'dirlist'),'R')
  57.     do until eof(List)
  58.         File = readln(List)
  59.         if File = '' then iterate
  60.         call DateCopy(File)
  61.         end
  62.     call close(List)
  63.     end
  64. ;;;
  65. /* ;;; Exit */
  66. if Updated = 1 then call ShowMsg('All index files are up to date')
  67. exit
  68. ;;;
  69. /* ;;; Copy new files */
  70. CopyFiles:
  71.     FileList = showdir(SrcDir)
  72.     do i = 1 to words(FileList)
  73.         if MatchPattern(Pattern,word(FileList,i),NOCASE,PARSED) then call DateCopy(word(FileList,i))
  74.         end
  75.     return
  76. ;;;
  77. /* ;;; Copy updated files */
  78. DateCopy:
  79.     parse arg FileName
  80.     if word(statef(AddPart(SrcDir,FileName)),5) > word(statef(AddPart(DestDir,FileName)),5) then do
  81.         address command 'Copy >NIL:' AddPart(SrcDir,FileName) DestDir 'CLONE'
  82.         Updated = 1
  83.         end
  84.     return
  85. ;;;
  86. /* ;;; Load a library */
  87. LoadLib:
  88.     parse arg library
  89.     if show('L',library) then return
  90.     if ~exists('LIBS:'library) then address command 'copy System/Libs/'library 'LIBS: clone quiet'
  91.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  92.     return
  93. ;;;
  94. /* ;;; ShowMsg */
  95. ShowMsg:
  96.     parse arg msg
  97.     address command 'RequestChoice >NIL: "Amiga Active CD" "'msg'" "OK"'
  98.     return
  99. ;;;
  100. /* ;;; Error handler */
  101. Error:
  102.     call ShowMsg('Error' RC 'in line' sigl)
  103.     if RC > 5 then exit
  104.     return
  105. ;;;
  106.  
  107.